<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改简历')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-resume-edit" th:object="${resume}">
            <h4 class="form-header h4">简历信息</h4>
            <input name="resId" th:field="*{resId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">简历文件路径：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="resFile" th:field="*{resFile}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="resFile" name="file" type="file">
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">面试回数：</label>
                <div class="col-sm-8">
                    <input name="resNo" th:field="*{resNo}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">面试状态：</label>
                <div class="col-sm-8">
                    <input name="resStatus" th:field="*{resStatus}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">面试者姓名：</label>
                <div class="col-sm-8">
                    <input name="resName" th:field="*{resName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">面试者性别：</label>
                <div class="col-sm-8">
                    <select name="resSex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}" required>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{resSex}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">联系电话：</label>
                <div class="col-sm-8">
                    <input name="resTel" th:field="*{resTel}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">学历：</label>
                <div class="col-sm-8">
                    <input name="resDegree" th:field="*{resDegree}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">毕业时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="resGdate" th:value="${#dates.format(resume.resGdate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">毕业院校：</label>
                <div class="col-sm-8">
                    <input name="resGraduate" th:field="*{resGraduate}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">专业：</label>
                <div class="col-sm-8">
                    <input name="resSpeciality" th:field="*{resSpeciality}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主要技术：</label>
                <div class="col-sm-8">
                    <input name="resTechnology" th:field="*{resTechnology}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">语言水平：</label>
                <div class="col-sm-8">
                    <input name="resLanguage" th:field="*{resLanguage}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">现在的公司：</label>
                <div class="col-sm-8">
                    <input name="resCompany" th:field="*{resCompany}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">简历的来源：</label>
                <div class="col-sm-8">
                    <input name="resOrigin" th:field="*{resOrigin}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">内部推荐人：</label>
                <div class="col-sm-8">
                    <input name="resUser" th:field="*{resUser}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">简历执行人 负责人：</label>
                <div class="col-sm-8">
                    <input name="resAction" th:field="*{resAction}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">参考的ban范围：</label>
                <div class="col-sm-8">
                    <input name="resBan" th:field="*{resBan}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">参考的职位：</label>
                <div class="col-sm-8">
                    <input name="resJob" th:field="*{resJob}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">添加人：</label>
                <div class="col-sm-8">
                    <input name="cu" th:field="*{cu}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">添加时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="ct" th:value="${#dates.format(resume.ct, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">修改人：</label>
                <div class="col-sm-8">
                    <input name="uu" th:field="*{uu}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">修改时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="ut" th:value="${#dates.format(resume.ut, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <h4 class="form-header h4">comments信息</h4>
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>
                    <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>
                    <div class="col-sm-12 select-table table-striped">
                        <table id="bootstrap-table"></table>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "system/resume";
        $("#form-resume-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-resume-edit').serialize());
            }
        }

        $("input[name='resGdate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='ct']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='ut']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });

        $(function() {
            var options = {
                data: [[${resume.commentsList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: "序号",
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'comText',
                    align: 'center',
                    title: '备注描述',
                    formatter: function(value, row, index) {
                        var html = $.common.sprintf("<input class='form-control' type='text' name='commentsList[%s].comText' value='%s'>", index, value);
                        return html;
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                comText: "",
                cu: "",
                ct: "",
                uu: "",
                ut: "",
            }
            sub.addRow(row);
        }
    </script>
</body>
</html>